package com.jr.service.impl;

import com.jr.dao.EnterpriseDao;
import com.jr.dao.UserDao;
import com.jr.dao.impl.EnterpriseDaoImpl;
import com.jr.dao.impl.UserDaoImpl;
import com.jr.entry.Enterprise;
import com.jr.entry.User;
import com.jr.service.EnterpriseService;

import java.util.ArrayList;

public class EnterpriseServiceImpl implements EnterpriseService {
EnterpriseDao enterpriseDao=new EnterpriseDaoImpl();
UserDao userDao=new UserDaoImpl();

    @Override
    public boolean insertEnterprise(Enterprise enterprise) {
        return enterpriseDao.insertEnterprise(enterprise);
    }

    @Override
    public Enterprise selectEnterpriseByAccount(String account) {
        User user = userDao.selectUserByAccount(account);
        System.out.println(user);
        System.out.println(userDao.selectUserByAccount(account).getEnterpriseId()+"....###***");
        return enterpriseDao.selectEnterpriseById(userDao.selectUserByAccount(account).getEnterpriseId());
    }

    @Override
    public ArrayList<Enterprise> selectAllEnterprise() {
        return enterpriseDao.selectAllEnterprise();

    }

    @Override
    public ArrayList<Enterprise> selectAllEnterpriseNotInBlack(Integer id,String account) {
        return enterpriseDao.selectAllEnterpriseNotInBlack(id,account);
    }

    @Override
    public Enterprise selectEnterpriseByName(String name) {
        return enterpriseDao.selectEnterpriseByName(name);
    }
}
